package com.hxminer.hxwebs.repository;

import com.hxminer.hxwebs.model.OrderDetails;
import com.hxminer.hxwebs.model.Orders;
import com.hxminer.hxwebs.model.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.CrudRepository;

import java.util.List;

/**
 * Author YRG
 * Created by on 2018/5/17.
 * Describe
 */
public interface OrdersDetailRepository extends CrudRepository<OrderDetails, User> {

    /**
     * 通过用户名和Id获取订单信息
     *
     * @param username
     * @param userId
     * @return
     */
    Page<OrderDetails> findAllByUsernameAndUserId(String username, String userId, Pageable pageable);


    /**
     * 获取
     *
     * @param username
     * @param userId
     * @param orderNo
     * @return
     */
    Page<OrderDetails> findAllByUsernameAndUserIdAndOrderNo(String username, String userId, String orderNo, Pageable
            pageable);

    /**
     * 是否支付
     *
     * @param username
     * @param userId
     * @param orderNo
     * @param isCompletePay
     * @return
     */
    Page<OrderDetails> findAllByUsernameAndUserIdAndOrderNoAndIsCompletePay(String username, String userId, String orderNo, Integer isCompletePay,Pageable pageable);


    /**
     * @param username
     * @param userId
     * @param isCompletePay
     * @param pageable
     * @return
     */
    List<OrderDetails> findAllByUsernameAndUserIdAndIsCompletePay(String username, String userId, Integer isCompletePay, Pageable pageable);

    /**
     * 获取订单
     *
     * @param username
     * @param userId
     * @param isCompletePay
     * @param pageable
     * @return
     */
    Page<OrderDetails> findByUsernameAndUserIdAndIsCompletePay(String username, String userId, Integer isCompletePay, Pageable pageable);


    List<OrderDetails> findAll(Pageable pageable);
}
